const state = {
	initData:'初始化数据',
	num:1,
	todos:[],//todos数据
}
const getters = {
	getNTodos(state){
		return (n)=>{
			return state.todos.slice(0,n)
		}
	}
}
const mutations = {
	changeTodos(state,payload){
		state.todos = payload
	},
	changeNum(state,payload){
		state.num += payload
	}
}
const actions = {
	getTodos({commit}){
		uni.request({
			url:'https://mock.mengxuegu.com/mock/636a17b488ed56479c2021f6/example/mock',
			method:'GET',
			success: (data) => {
				commit('changeTodos',data.data.data.projects)
				console.log(data.data.data.projects);
			},
			fail: (error) => {
				console.log(error);
			}
		})
	}
}

export default {
	namespaced:true,
	state,
	getters,
	mutations,
	actions
}